---
# Install additional packages
- import_tasks: install.yml

# Create database for faf
- import_tasks: setup_db.yml

# Allow https and start httpd
- import_tasks: services.yml

# landing page
- name: install abrt-server-info-page
  package: name=abrt-server-info-page state=latest

- name: configure ADMINS
  lineinfile:
    dest: /usr/lib/python2.7/site-packages/abrt-server-info-page/config.py
    regexp: 'ADMINS ='
    line: '    ADMINS = "infrastructure@lists.fedoraproject.org"'
  notify: restart httpd

- name: configure MORE_FAF
  lineinfile:
    dest: /usr/lib/python2.7/site-packages/abrt-server-info-page/config.py
    regexp: 'MORE_FAF ='
    line: '    MORE_FAF = "https://github.com/abrt/faf/"'
  notify: restart httpd

- name: configure MORE_RS
  lineinfile:
    dest: /usr/lib/python2.7/site-packages/abrt-server-info-page/config.py
    regexp: 'MORE_RS ='
    line: '    MORE_RS = "https://github.com/abrt/retrace-server"'
  notify: restart httpd

- name: configure MORE_ABRT
  lineinfile:
    dest: /usr/lib/python2.7/site-packages/abrt-server-info-page/config.py
    regexp: 'MORE_ABRT ='
    line: '    MORE_ABRT = "https://github.com/abrt/abrt/"'
  notify: restart httpd

- name: configure MORE_GABRT
  lineinfile:
    dest: /usr/lib/python2.7/site-packages/abrt-server-info-page/config.py
    regexp: 'MORE_GABRT ='
    line: '    MORE_GABRT = "https://github.com/abrt/gnome-abrt/"'
  notify: restart httpd

- name: configure MORE_LR
  lineinfile:
    dest: /usr/lib/python2.7/site-packages/abrt-server-info-page/config.py
    regexp: 'MORE_LR ='
    line: '    MORE_LR = "https://github.com/abrt/libreport/"'
  notify: restart httpd

- name: configure MORE_SATYR
  lineinfile:
    dest: /usr/lib/python2.7/site-packages/abrt-server-info-page/config.py
    regexp: 'MORE_SATYR ='
    line: '    MORE_SATYR = "https://github.com/abrt/satyr/"'
  notify: restart httpd

# the magic with ! is that it return exit code 1 if 'already defined' is not present in output
- name: add repositories
  shell: ! faf repoadd --nogpgcheck "{{ item.name }}" yum "{{ item.url }}" 2>&1 | grep 'already defined'
  become: yes
  become_user: faf
  ignore_errors: yes
  when: not devel
  tags: add_repo
  with_items: "{{ faf_repos }}"

- name: repoassign repositories
  command: faf repoassign "{{ item.name }}" "{{ item.opsys }}" "{{ item.arch }}"
  become: yes
  become_user: faf
  when: not devel
  tags: add_repo
  with_items: "{{ faf_repos }}"

- import_tasks: cron.yml
  tags: cron
